package DataStructureAndAlgorithm.AcWing_每日一题.枚举;

//链接：https://www.acwing.com/problem/content/3812/

import java.util.Scanner;
//看数据范围，直接暴力枚举，无敌
class AcWing_3809{
    public static void main(String[] args){
        Scanner in = new Scanner(System.in);
        int t = in.nextInt();
        for (int k = 0; k < t; k++){
            int n = in.nextInt();
            int[] nums = new int[n];
            int max = 0;
            //先读入所有数
            for (int i = 0; i < n; i++){
                nums[i] = in.nextInt();
                max = Math.max(max,nums[i]);
            }
            //从1到100之间直接枚举答案即可
            int res_t = 0,res_c = 100000000;

            for (int j = 1; j <= max; j++){
                int temp_c = 0;
                for (int i = 0; i < n; i++){
                    if (Math.abs(nums[i] - j) > 1)
                        //减1，是因为不需要两个点重合，只需两点距离在一以内，即可取得min
                        temp_c += Math.abs(nums[i] - j) - 1;
                }
                if (temp_c < res_c){
                    res_c = temp_c;
                    res_t = j;
                }
            }
            System.out.println(res_t + " " + res_c);

        }
        in.close();
    }
}